package com.jt.controller;

import com.jt.pojo.AxiosPojo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class AxiosController {
    /**
     * axios入门
     */
    @GetMapping("/hello")
    public String hello(){

        return "VUE的ajax异步调用";
    }

    /**
     * axios带参
     */
    @GetMapping("/param")
    public String param(Integer id){

        return "带参的axios请求，参数"+id;
    }

    /**
     * axios RestFul风格
     */
    @GetMapping("/paramRest/{id}/{name}")
    public String paramRest(@PathVariable Integer id,@PathVariable String name){

        return id+":"+name;
    }

    /**
     * axios POST
     * @RequestBody:接收前端请求的JSON串并转换成对象赋值
     */
    @PostMapping("/postAxios")
    public AxiosPojo postAxios(@RequestBody AxiosPojo axiosPojo){
        return axiosPojo;
    }

    /**
     * axios POST form
     */
    @PostMapping("/postForm")
    public AxiosPojo postForm( AxiosPojo axiosPojo){
        return axiosPojo;
    }


}
